package com.xbongbong.pro.message.model.impl;/*/*/

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.paas.toolbox.wrap.IEntity;
import com.xbongbong.message.domain.dao.PushSetDao;
import com.xbongbong.message.domain.entity.PushSetEntity;
import com.xbongbong.pro.message.model.PushSetModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * Description: PushSetModel 实现
 * @author 魏荣杰
 * @date 2019/1/6 1:12
 * @version v1.0
 * @since v1.0
 */
@Service("pushSetModel")
public class PushSetModelImpl implements PushSetModel{

    @Resource
    private PushSetDao pushSetDao;

    @Override
    public Integer insert(PushSetEntity entity){
        Integer now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);

        return pushSetDao.insert(entity);
    }

    @Override
    public Integer update(PushSetEntity entity){
        entity.setUpdateTime(DateUtil.getInt());

        return pushSetDao.update(entity);
    }

    @Override
    public Integer updateBatch(List<PushSetEntity> list,String corpid){
        return pushSetDao.updateBatch(list,corpid);
    }

    @Override
    public List<PushSetEntity> findEntitys(Map<String ,Object> param){
        return pushSetDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String ,Object>  param){
        return pushSetDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }


    @Override
    public Integer save(PushSetEntity entity){
        Integer now = DateUtil.getInt();
        entity.setUpdateTime(now);
        if(entity.getId() == null || Objects.equals(0, entity.getId())) {
            entity.setAddTime(now);
            return pushSetDao.insert(entity);
        }
        return pushSetDao.update(entity);
    }


    @Override
    public Integer deleteByKey(Long key, String corpid){
        return pushSetDao.deleteByKey(key, corpid);
    }

    @Override
    public PushSetEntity getByKey(Long key, String corpid){
        return pushSetDao.getByKey(key, corpid);
    }


}
